package character;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.scene.Node;
import java.io.IOException;
import mygame.MyCharacterControl;

public class HumanoidCharacter extends AbstractCharacter {

    public HumanoidCharacter() {}

    public HumanoidCharacter(Node model, CharacterSettings settings, MyCharacterControl characterControl) {
	super(model, settings, characterControl);
	init();
    }

    private void init() {
	//set up animation control
	AnimControl animControl = getModel().getControl(AnimControl.class);
	if(animControl != null) {
	    animControl.addListener(getControl(MyCharacterControl.class));
	    AnimChannel walkChannel = animControl.createChannel();
	    walkChannel.setAnim(AbstractCharacter.CHARACTER_ANIM_STAND);
	}
    }

    @Override
    public void write(JmeExporter ex) throws IOException {
	super.write(ex);
    }

    @Override
    public void read(JmeImporter im) throws IOException {
	super.read(im);

	//AnimControl junk isn't saved, so we have to re-init it on load
	init();
    }
}
